home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
vs
/
browser
/
cpb10eb.exe
/
DATA.Z
/
doll.java
< prev
next >
Wrap
Text File
|
1996-09-25
|
1KB
|
53 lines
//
// doll.java
// click the parts of the doll to change color
//
// (c) Copyright 1996 Sony Corporation. All rights reserved.
import vrml.*;
import vrml.field.*;
import vrml.node.*;
import java.util.*;
public class doll extends Script {
final int PARTS_MAX = 18;
SFColor mat[] = new SFColor[ PARTS_MAX ];
SFInt32 no[] = new SFInt32 [ PARTS_MAX ];
SFNode node;
String str;
SFColor color;
SFInt32 colorno;
public void processEvent(Event e){
// System.out.println( "event" + e.getName());
String str = e.getName();
if( str.startsWith( "clicked" )){
Integer ii = new Integer (str.substring( 7 ));
int i = ii.intValue();
if ( i >= 0 && i < PARTS_MAX ){
mat[ i ].setValue( color );
no[ i ].setValue( colorno );
// System.out.println( i );
}
}
}
public void initialize (){
String str;
for( int i = 0; i < PARTS_MAX; i++ ){
str = "mat" + i;
mat[ i ] = ( SFColor ) getEventOut( str ) ;
str = "no" + i;
no[ i ] = ( SFInt32 ) getEventOut( str ) ;
}
// get currentColor
color = (SFColor) getField( "currentColor" );
colorno = (SFInt32) getField( "currentColorNo" );
// System.out.println( "init" );
}
}